#ifndef __QUAD3D_H__
#define __QUAD3D_H__

#include "vector3d.h"

template <class T>
class quad3d
{
public:
	vector3d<T> Top;
	vector3d<T> Down;

public:
	quad3d()																											{}
	quad3d(T nx, T ny, T nz, T nx2, T ny2, T nz2) : Top(vector3d<T>(nx,ny,nz)), Down(vector3d<T>(nx2,ny2,nz2))			{}
	quad3d(const quad3d<T>& other) : Top(other.Top), Down(other.Down)													{}
	virtual ~quad3d()																									{}

	virtual bool IsPointInside(T x, T y,T z)
	{
		bool XInside(false);
		bool YInside(false);
		bool ZInside(false);

		if (Down.X > Down.X)
			XInside = (x > Down.X && x < Down.X);
		else
			XInside = (x < Down.X && x > Down.X);

		if (XInside)
			if (Down.Y > Down.Y)
				YInside = (y > Down.Y && y < Down.Y);
			else
				YInside = (y < Down.Y && y > Down.Y);

		if (XInside && YInside)
			if (Down.Z > Down.Z)
				ZInside = (z > Down.Z && z < Down.Z);
			else
				ZInside = (z < Down.Z && z > Down.Z);

		return XInside && YInside && ZInside;
	}

	virtual bool IsPointInside(vector3d<T> Point)	{	return IsPointInside(Point.X,Point.Y,Point.Z);	}

};

typedef quad3d<vPos> quad3dvpos;
typedef quad3d<f32> quad3df32;
typedef quad3d<u32> quad3du32;
typedef quad3d<s32> quad3ds32;
typedef quad3d<u16> quad3du16;
typedef quad3d<s16> quad3ds16;
typedef quad3d<u8> quad3du8;
typedef quad3d<s8> quad3ds8;

#endif
